package com.hu.bgp.server.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import com.hu.bgp.server.Persistence;

/**
 * De score entity. Deze zit in een ander schema dan de rest van de entiteiten
 * en moet dus op een speciale manier met z'n relaties omgaan.
 * 
 * @author ejvos
 */
@Entity
@Table(name = "bgp_scores")
public class Score
{
	@Id
	private int id;
	@Column
	private String gameTypeAlias;
	@Column
	private int profileId;
	@Column
	private String scoreText;

	/**
	 * Always have an empty constructor for entities.
	 */
	public Score()
	{
	}

	public void setId(int id)
	{
		this.id = id;
	}

	public int getId()
	{
		return id;
	}

	public void setGameTypeAlias(String gameTypeAlias)
	{
		this.gameTypeAlias = gameTypeAlias;
	}

	public String getGameTypeAlias()
	{
		return gameTypeAlias;
	}

	public void setProfileId(int profileId)
	{
		this.profileId = profileId;
	}

	public int getProfileId()
	{
		return profileId;
	}

	public void setScoreText(String scoreText)
	{
		this.scoreText = scoreText;
	}

	public String getScoreText()
	{
		return scoreText;
	}

	// DAO methods
	public Profile getProfile(Persistence p)
	{
		Profile profile = p.getDefaultServer().find(Profile.class, profileId);
		return profile;
	}

	public void save(Persistence p)
	{
		p.getScoreServer().save(this);
	}
}
